package xu.ye.view.adapter;

import java.util.List;

import com.agent.crm.view.R;

import xu.ye.bean.GroupBean;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class GroupContactAdapter extends BaseAdapter{
    private Context ctx;
    private List<GroupBean> list;
    private LayoutInflater inflater;
    
    public GroupContactAdapter(Context ctx, List<GroupBean> list){
        this.ctx = ctx;
        this.list = list;
        this.inflater = LayoutInflater.from(ctx);
    }
    
    
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.group_list_item, null);
            holder = new ViewHolder();
            holder.name = (TextView)convertView.findViewById(R.id.groupNameId);
            holder.count = (TextView)convertView.findViewById(R.id.groupCountId);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag(); 
        }
        
        GroupBean cb = list.get(position);
        holder.name.setText(cb.getName());
        holder.name.setTextColor(Color.BLACK);
        //holder.count.setText(cb.getCount() + "");
        holder.count.setTextColor(Color.BLACK);
        return convertView;
    }
    
    
    
    private static class ViewHolder {
        TextView name;
        TextView count;
        
    }

}
